<script type="text/html" template lay-done="layui.data.done(d);">
</script>
<div class="table-body">
    <table id="LAY-app-CoreCmsArticleType-tableBox" lay-filter="LAY-app-CoreCmsArticleType-tableBox"></table>
</div>

<script>
    var indexData;
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d); }

        indexData = d.data;
        layui.use(['index', 'table', 'laydate', 'util', 'coreHelper'],
            function () {
                var $ = layui.$
                    , admin = layui.admin
                    , table = layui.table
                    , form = layui.form
                    , laydate = layui.laydate
                    , setter = layui.setter
                    , coreHelper = layui.coreHelper
                    , util = layui.util
                    , treeTable = layui.treeTable
                    , view = layui.view;

                //重载form
                form.render();
                var searchwhere;

                //数据绑定
                var insTb = treeTable.render({
                    id: 'treeTableBox',
                    url: layui.setter.apiUrl + 'Api/Tools/GetGoodTypes',
                    elem: '#LAY-app-CoreCmsArticleType-tableBox',
                    method: 'POST',
                    tree: {
                        customName: {
                            id: 'id',
                            pid: 'parentId',
                            name: 'title',
                        },
                        view: {
                            showIcon: false,
                            indent: 25
                        },
                        data: {
                            //isSimpleData: true,
                        },
                        callback: {}
                    },
                    height: 'full-232',//无面包屑127,搜索框189,1行62
                    cols: [[
                        { field: 'id', title: '序列', width: 60, sort: false },
                        { field: 'title', title: '名称', sort: false },
                        {
                            field: 'sort', title: '排序', sort: false, width: 105, templet: function (d) {
                                return d.otherData.sort
                            }
                        },
                        {
                            field: 'imageUrl', title: '图片', width: 80, sort: false,
                            templet: function (d) {
                                if (d.otherData.imageUrl) {
                                    return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + d.otherData.imageUrl + '")><image style="max-width:28px;max-height:28px;" src="' + d.otherData.imageUrl + '" /></a>';
                                } else {
                                    return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + setter.noImagePicUrl + '")><image style="max-width:30px;max-height:30px;" src="' + setter.noImagePicUrl + '" /></a>';
                                }
                            }
                        },
                        { width: 140, title: '操作', align: 'center', toolbar: '#articleTypeBar' }
                    ]],
                    done: function (res, curr, count) {
                        treeTable.expandAll('treeTableBox', true);
                    },
                    page: false
                });
            });
    };
</script>

<script type="text/html" id="articleTypeBar">
    <a class="layui-btn layui-btn-xs" lay-event="selectType">选择</a>
</script>